/*
 * Copyright 2017 Yofc.com All right reserved. This software is the
 * confidential and proprietary information of Yofc.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Yofc.com.
 */
package fangboss.com.dal.generator;

import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.internal.DefaultShellCallback;

import java.util.ArrayList;
import java.util.List;

/**
 * <pre>
 *   自动生成mybatis-Mapper工具
 * </pre>
 * Created by sirius on 2018/9/17.
 *
 * @author sirius
 * @since 1.0
 */

public class GeneratorDemo {

    public static void main(String[] args) throws Exception {


        List<String> warnings = new ArrayList<String>();
        ConfigurationParser cp = new ConfigurationParser(warnings);
        Configuration config = cp.parseConfiguration(GeneratorDemo.class.getClassLoader().getResourceAsStream("generatorConfig.xml"));
        DefaultShellCallback shellCallback = new DefaultShellCallback(true);

        try {
            MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
            myBatisGenerator.generate(null);
        } catch (InvalidConfigurationException e) {
//              assertEquals(2, e.getErrors().size());
            throw e;
        }
        for (String warning : warnings) {
            System.out.println(warning);
        }
        System.out.println("generator execute success!");

    }

}
